home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / web / reduce / rweb / appl / source / integrator.red < prev    next >
Encoding:
Text File  |  1991-12-17  |  26.8 KB  |  992 lines

  1. %5:%
  2. %line 72 "integrator.web"
  3.  
  4. symbolic$
  5. write"Integrator package for REDUCE 3.4, $Revision: 0.92 $"$terpri()$
  6. %9:%
  7. %line 213 "integrator.web"
  8.  
  9. %line 214 "integrator.web"
  10. put( 'initialize_equations, 'psopfn, 'initialize_equations1)$
  11.  
  12. %:9%%13:%
  13. %line 294 "integrator.web"
  14.  
  15.  
  16. global '(current_equation_set!*)$
  17. current_equation_set!*:= 'equ$
  18.  
  19. %:13%%18:%
  20. %line 382 "integrator.web"
  21.  
  22.  
  23.  
  24. fluid '(!*coefficient_check)$
  25. !*coefficient_check:=t$
  26. flag( '(coefficient_check), 'switch)$
  27.  
  28. %:18%%30:%
  29. %line 597 "integrator.web"
  30.  
  31. %line 598 "integrator.web"
  32.  
  33.  
  34. fluid '(!*polynomial_check)$
  35. !*polynomial_check:=nil$
  36. flag( '(polynomial_check), 'switch)$
  37.  
  38. %:30%%50:%
  39. %line 955 "integrator.web"
  40.  
  41. %line 956 "integrator.web"
  42.  
  43.  
  44. fluid '(!*allow_differentiation)$
  45. !*allow_differentiation:=nil$
  46. flag( '(allow_differentiation), 'switch)$
  47.  
  48. %:50%%61:%
  49. %line 1185 "integrator.web"
  50.  
  51. %line 1186 "integrator.web"
  52.  
  53. fluid '(listpri_depth!*)$
  54. listpri_depth!*:=40$
  55.  
  56. %:61%
  57. %line 75 "integrator.web"
  58.  
  59. algebraic$
  60.  
  61. %:5%%10:%
  62. %line 217 "integrator.web"
  63.  
  64. %line 218 "integrator.web"
  65. lisp procedure initialize_equations1 specification_list;
  66. begin scalar operator_name,total_used,variable_list,
  67. specification,even_used,odd_used,
  68. constant_operator,bracketname,function_name,function_list;
  69. if length specification_list<5 then
  70. rederr("INITIALIZE_EQUATIONS: wrong number of parameters");
  71. if not idp(operator_name:=car specification_list)then
  72. rederr("INITIALIZE_EQUATIONS: equations operator must be identifier");
  73. if not fixp(total_used:=
  74. reval car(specification_list:=cdr specification_list))
  75. or total_used<0 then
  76. rederr("INITIALIZE_EQUATIONS: total number of equations must be positive");
  77. put(operator_name, 'total_used,total_used);
  78. variable_list:=reval car(
  79. specification_list:=cdr specification_list);
  80. if atom variable_list or car variable_list neq 'list then
  81. rederr("INITIALIZE_EQUATIONS: variable list must be algebraic list");
  82. put(operator_name, 'variable_list,cdr variable_list);
  83. %11:%
  84. %line 265 "integrator.web"
  85.  
  86. specification_list:=cdr specification_list;
  87. specification:=car specification_list;
  88.  
  89. if atom specification or length specification neq 4 or car specification neq 'list
  90. or not idp(constant_operator:=cadr specification)or
  91. not fixp(even_used:=reval caddr specification)or
  92. not fixp(odd_used:=reval cadddr specification)
  93. or even_used<0 or odd_used<0 then
  94.  
  95. msgpri("INITIALIZE_EQUATIONS: invalid declaration of",
  96. specification,nil,nil,t);
  97. put(operator_name, 'constant_operator,constant_operator);
  98. if get(constant_operator, 'rtype)= 'algebra_generator then
  99. put(operator_name, 'bracketname,
  100. bracketname:=get(constant_operator, 'bracketname));
  101.  
  102. if get(constant_operator, 'rtype)= 'algebra_generator then
  103. define_used(bracketname,list( 'list,even_used,odd_used))
  104. else
  105. begin
  106. put(constant_operator, 'even_used,even_used);
  107. put(constant_operator, 'odd_used,odd_used);
  108. end
  109.  
  110. %:11%
  111. %line 236 "integrator.web"
  112. ;
  113. %12:%
  114. %line 276 "integrator.web"
  115.  
  116. %line 277 "integrator.web"
  117. for each function_specification in cdr specification_list do
  118. begin
  119.  
  120. if atom function_specification or length function_specification neq 4 or car function_specification neq 'list
  121. or not idp(function_name:=cadr function_specification)or
  122. not fixp(even_used:=reval caddr function_specification)or
  123. not fixp(odd_used:=reval cadddr function_specification)
  124. or even_used<0 or odd_used<0 then
  125.  
  126. msgpri("INITIALIZE_EQUATIONS: invalid declaration of",
  127. function_specification,nil,nil,t);
  128.  
  129. if get(function_name, 'rtype)= 'algebra_generator then
  130. define_used(bracketname,list( 'list,even_used,odd_used))
  131. else
  132. begin
  133. put(function_name, 'even_used,even_used);
  134. put(function_name, 'odd_used,odd_used);
  135. end;
  136. function_list:=function_name . function_list;
  137. end;
  138. put(operator_name, 'function_list,function_list)
  139.  
  140. %:12%
  141. %line 237 "integrator.web"
  142. ;
  143. end$
  144.  
  145. %:10%%14:%
  146. %line 298 "integrator.web"
  147.  
  148. %line 299 "integrator.web"
  149. lisp operator use_equations;
  150. lisp procedure use_equations operator_name;
  151. begin
  152. if idp operator_name then
  153. current_equation_set!*:=operator_name
  154. else rederr("USE_EQUATIONS: argument must be identifier");
  155. end$
  156.  
  157. %:14%%15:%
  158. %line 315 "integrator.web"
  159.  
  160. %line 316 "integrator.web"
  161. lisp operator integrate_equation;
  162. lisp procedure integrate_equation n;
  163. begin scalar listpri_depth!*,total_used,equation,denominator,
  164. solvable_kernel,solvable_kernels,df_list,df_kernel,
  165. function_list,present_functions_list,variable_list,absent_variables,
  166. polynomial_variables,equations_list,linear_functions_list,constants_list,
  167. bracketname,df_terms,df_functions,
  168. linear_functions,functions_and_constants_list,commutator_functions,
  169. present_variables,
  170. inhomogeneous_term,nr_of_variables,integration_variables,
  171. forbidden_functions,differentiations_list,polynomial_order;
  172. listpri_depth!*:=200;
  173. terpri!* t;
  174. %16:%
  175. %line 348 "integrator.web"
  176.  
  177. if null(total_used:=get(current_equation_set!*, 'total_used))or
  178. n>total_used then
  179.  
  180. msgpri("INTEGRATE_EQUATIONS: properly initialize",
  181. current_equation_set!*,nil,nil,t);
  182. if null(equation:=cadr assoc(list(current_equation_set!*,n),
  183. get(current_equation_set!*, 'kvalue)))then
  184.  
  185. msgpri("INTEGRATE_EQUATION:",list(current_equation_set!*,n),
  186. "is non-existent",nil,t);
  187. denominator:=denr(equation:=simp!* equation);
  188. equation:=numr equation;
  189. if null equation then
  190.  <<write current_equation_set!*,"(",n,") = 0";terpri!* t;
  191.  
  192. setk(list(current_equation_set!*,n),0);goto solved>> 
  193.  
  194. %:16%
  195. %line 329 "integrator.web"
  196. ;
  197. %19:%
  198. %line 398 "integrator.web"
  199.  
  200. df_list:=split_form(equation, '(df));
  201. if null car df_list and
  202. (cdr df_list)and length(cdr df_list)=1
  203. then
  204. if(solvable_kernel:=find_solvable_kernel(
  205. solvable_kernels:=list(car car cdr df_list),
  206. cdr df_list,denominator))then
  207.  <<df_kernel:=cadr solvable_kernel;
  208. setk(df_kernel,homogeneous_integration_of(solvable_kernel));
  209. depl!*:=
  210. delete(assoc(df_kernel,depl!*),depl!*);
  211.  
  212.  
  213.  <<write current_equation_set!*,"(",n,"): ","Homogeneous integration of ";maprin solvable_kernel;terpri!* nil;
  214.  
  215. setk(list(current_equation_set!*,n),0);goto solved>> >> 
  216. else
  217.  <<write"*** ",current_equation_set!*,"(",n,"): ","Homogeneous integration"," failed:";terpri!* t;
  218. write"    coefficient not a number for ";
  219. maprin
  220. car solvable_kernels;terpri!* nil;
  221. write"    Solvable with 'off coefficient_check'";
  222. terpri!* t;goto solved>> 
  223.  
  224. %:19%
  225. %line 330 "integrator.web"
  226. ;
  227. %27:%
  228. %line 568 "integrator.web"
  229.  
  230. %28:%
  231. %line 576 "integrator.web"
  232.  
  233. %line 577 "integrator.web"
  234. function_list:=get(current_equation_set!*, 'function_list);
  235. present_functions_list:=get_recursive_kernels(equation,function_list);
  236. variable_list:=get(current_equation_set!*, 'variable_list);
  237. absent_variables:=variable_list;
  238. for each function in present_functions_list do
  239. for each variable in
  240. ((if depl_entry then cdr depl_entry)where depl_entry=assoc(function,depl!*))do
  241. absent_variables:=delete(variable,absent_variables)
  242.  
  243. %:28%
  244. %line 569 "integrator.web"
  245. ;
  246. %29:%
  247. %line 591 "integrator.web"
  248.  
  249. %line 592 "integrator.web"
  250. polynomial_variables:=absent_variables;
  251. if !*polynomial_check then
  252. polynomial_variables:=for each variable in polynomial_variables join
  253. if polynomialp(equation,variable)then list(variable)
  254.  
  255. %:29%
  256. %line 570 "integrator.web"
  257. ;
  258. %32:%
  259. %line 614 "integrator.web"
  260.  
  261. %line 615 "integrator.web"
  262. equations_list:=multi_split_form(equation,polynomial_variables);
  263. if length equations_list>1 then
  264.  <<for each pc_pair in cdr
  265. equations_list do
  266. setk(list(current_equation_set!*,(total_used:=total_used+1)),
  267. mk!*sq((cdr pc_pair) ./ 1));
  268. if car equations_list then
  269. setk(list(current_equation_set!*,(total_used:=total_used+1)),
  270. mk!*sq((car equations_list) ./ 1));
  271. write current_equation_set!*,"(",n,") breaks into ",
  272. current_equation_set!*,"(",get(current_equation_set!*, 'total_used)+1,
  273. "),...,",current_equation_set!*,"(",total_used,") by ";
  274. maprin partial_list(polynomial_variables,5);
  275. terpri!* nil;
  276.  
  277. setk(list(current_equation_set!*,n),0);
  278. put(current_equation_set!*, 'total_used,total_used);
  279. goto solved
  280. >> 
  281.  
  282. %:32%
  283. %line 571 "integrator.web"
  284.  
  285.  
  286. %:27%
  287. %line 331 "integrator.web"
  288. ;
  289. %34:%
  290. %line 652 "integrator.web"
  291.  
  292. %line 653 "integrator.web"
  293. linear_functions_list:=split_form(car df_list,
  294. function_list);
  295. df_list:=cdr df_list;
  296. constants_list:=split_form(car linear_functions_list,
  297. list get(current_equation_set!*, 'constant_operator));
  298. linear_functions_list:=cdr linear_functions_list;
  299. if(bracketname:=get(current_equation_set!*, 'bracketname))then
  300. %35:%
  301. %line 669 "integrator.web"
  302.  
  303. %line 670 "integrator.web"
  304. if length(df_list)=0 and
  305. length(linear_functions_list)=0 then
  306.  <<
  307. if atom(solvable_kernel:=
  308. relation_analysis(!*ff2a(equation,denominator),bracketname))
  309. then <<write current_equation_set!*,"(",n,") is a non-solvable Lie relation";
  310. terpri!* t>> 
  311. else <<write current_equation_set!*,"(",n,") solved for ";maprin solvable_kernel;
  312. terpri!* t;
  313. setk(list(current_equation_set!*,n),0)>> ;
  314. goto solved
  315. >> 
  316.  
  317. %:35%
  318. %line 660 "integrator.web"
  319.  
  320.  
  321. %:34%
  322. %line 332 "integrator.web"
  323. ;
  324. %36:%
  325. %line 710 "integrator.web"
  326.  
  327. %line 711 "integrator.web"
  328. %37:%
  329. %line 725 "integrator.web"
  330.  
  331. %line 726 "integrator.web"
  332. df_terms:=for each df_term in df_list join
  333. if member(car cadr car df_term,function_list)
  334. then list car df_term;
  335. for each df_term in df_terms do if not member(cadr
  336. df_term,df_functions)then df_functions:=cadr(df_term) . df_functions;
  337. functions_and_constants_list:=append(linear_functions_list,
  338. cdr constants_list);
  339. linear_functions:=for each linear_function in
  340. functions_and_constants_list collect car linear_function;
  341. if bracketname then commutator_functions:=
  342. get_recursive_kernels(car constants_list,
  343. get(current_equation_set!*, 'function_list));
  344.  
  345. %:37%
  346. %line 712 "integrator.web"
  347. ;
  348. %38:%
  349. %line 739 "integrator.web"
  350.  
  351. %line 740 "integrator.web"
  352. present_variables:=variable_list;
  353. for each variable in absent_variables do
  354. present_variables:=delete(variable,present_variables);
  355. nr_of_variables:=length present_variables
  356.  
  357. %:38%
  358. %line 713 "integrator.web"
  359. ;
  360. for each kernel in linear_functions do if length
  361.  
  362. ((if depl_entry then cdr depl_entry)where depl_entry=assoc(kernel,depl!*))=nr_of_variables then
  363. solvable_kernels:=kernel . solvable_kernels;
  364. for each kernel in append(df_functions,commutator_functions)do
  365. solvable_kernels:=delete(kernel,solvable_kernels);
  366. if solvable_kernels then
  367. %39:%
  368. %line 745 "integrator.web"
  369.  
  370. %line 746 "integrator.web"
  371.  <<solvable_kernel:=
  372. find_solvable_kernel(solvable_kernels,functions_and_constants_list,denominator);
  373. if solvable_kernel then
  374.  <<linear_solve_and_assign(!*ff2a(equation,1),solvable_kernel);
  375. depl!*:=
  376. delete(assoc(solvable_kernel,depl!*),depl!*);
  377.  
  378.  
  379.  <<write current_equation_set!*,"(",n,"): ","Solved for ";maprin solvable_kernel;terpri!* nil;
  380.  
  381. setk(list(current_equation_set!*,n),0);goto solved>> 
  382. >> 
  383. else
  384.  <<write"*** ",current_equation_set!*,"(",n,"): ","Solving a function"," failed:";terpri!* t;
  385. write"    coefficient not a number for ";
  386. maprin
  387. partial_list(solvable_kernels,3);terpri!* nil;
  388. write"    Solvable with 'off coefficient_check'";
  389. terpri!* t;goto solved>> 
  390. >> 
  391.  
  392. %:39%
  393. %line 720 "integrator.web"
  394.  
  395.  
  396. %:36%
  397. %line 333 "integrator.web"
  398. ;
  399. %40:%
  400. %line 772 "integrator.web"
  401.  
  402. %line 773 "integrator.web"
  403. %41:%
  404. %line 784 "integrator.web"
  405.  
  406. %line 785 "integrator.web"
  407. integration_variables:=present_variables;
  408. for each kernel in append(linear_functions,commutator_functions)do
  409. for each variable in
  410. ((if depl_entry then cdr depl_entry)where depl_entry=assoc(kernel,depl!*))do
  411. integration_variables:=delete(variable,integration_variables);
  412. for each df_function in df_functions do
  413. if not length
  414. ((if depl_entry then cdr depl_entry)where depl_entry=assoc(df_function,depl!*))=nr_of_variables then
  415. for each variable in
  416. ((if depl_entry then cdr depl_entry)where depl_entry=assoc(df_function,depl!*))do
  417. integration_variables:=delete(variable,integration_variables)
  418.  
  419. %:41%
  420. %line 773 "integrator.web"
  421. ;
  422. %43:%
  423. %line 813 "integrator.web"
  424.  
  425. %line 814 "integrator.web"
  426. %44:%
  427. %line 824 "integrator.web"
  428.  
  429. %line 825 "integrator.web"
  430. for each df_term in df_terms do
  431.  <<if length
  432. ((if depl_entry then cdr depl_entry)where depl_entry=assoc(cadr df_term,depl!*))=nr_of_variables
  433. and(check_differentiation_sequence(cdr cdr df_term,
  434. integration_variables)
  435. or member(cadr df_term,forbidden_functions))
  436. then solvable_kernels:=if member(cadr df_term,forbidden_functions)
  437. then list(nil,nil)else df_term . solvable_kernels;
  438. forbidden_functions:=(cadr df_term) . forbidden_functions>> ;
  439.  
  440. %:44%
  441. %line 814 "integrator.web"
  442. ;
  443. %45:%
  444. %line 834 "integrator.web"
  445.  
  446. %line 835 "integrator.web"
  447. if solvable_kernels then
  448. if length(solvable_kernels)=1 then
  449. if(solvable_kernel:=find_solvable_kernel(solvable_kernels,df_list,denominator))
  450. then
  451. if(inhomogeneous_term:=linear_solve(mk!*sq(equation ./ 1),solvable_kernel))
  452. and(not !*polynomial_check or
  453. check_polynomial_integration(solvable_kernel,inhomogeneous_term))
  454. then
  455.  <<df_kernel:=cadr solvable_kernel;
  456. setk(df_kernel,
  457. inhomogeneous_integration_of(solvable_kernel,inhomogeneous_term));
  458. depl!*:=
  459. delete(assoc(df_kernel,depl!*),depl!*);
  460.  
  461.  
  462.  <<write current_equation_set!*,"(",n,"): ","Inhomogeneous integration of ";maprin solvable_kernel;terpri!* nil;
  463.  
  464. setk(list(current_equation_set!*,n),0);goto solved>> >> 
  465. else
  466.  <<write current_equation_set!*,"(",n,"): Inhomogeneous integration failed: ";terpri!* t;
  467. write"inhomogeneous term not polynomial in integration variables";
  468. terpri!* t;goto solved>> 
  469. else
  470.  <<write"*** ",current_equation_set!*,"(",n,"): ","Inhomogeneous integration"," failed:";terpri!* t;
  471. write"    coefficient not a number for ";
  472. maprin
  473. car solvable_kernels;terpri!* nil;
  474. write"    Solvable with 'off coefficient_check'";
  475. terpri!* t;goto solved>> 
  476. else <<write current_equation_set!*,"(",n,"): Inhomogeneous integration failed: ";terpri!* t;
  477. write"more terms with maximal dependency";terpri!* t;goto solved>> 
  478.  
  479. %:45%
  480. %line 815 "integrator.web"
  481.  
  482.  
  483. %:43%
  484. %line 774 "integrator.web"
  485.  
  486.  
  487. %:40%
  488. %line 334 "integrator.web"
  489. ;
  490. %51:%
  491. %line 960 "integrator.web"
  492.  
  493. %line 961 "integrator.web"
  494. %52:%
  495. %line 993 "integrator.web"
  496.  
  497.  
  498. present_variables:=for each variable in present_variables collect
  499. (variable . nil . 0);
  500.  
  501. for each kernel in df_terms do
  502. for each variable in
  503. ((if depl_entry then cdr depl_entry)where depl_entry=assoc(cadr(kernel),depl!*))do
  504.  
  505. rplacd(entry,kernel . (cddr entry+1))
  506. where entry=assoc(variable,present_variables);;
  507.  
  508. for each kernel in linear_functions do
  509. for each variable in
  510. ((if depl_entry then cdr depl_entry)where depl_entry=assoc(kernel,depl!*))do
  511.  
  512. rplacd(entry,kernel . (cddr entry+1))
  513. where entry=assoc(variable,present_variables);;
  514. if bracketname then
  515. for each kernel in commutator_functions do
  516. for each variable in
  517. ((if depl_entry then cdr depl_entry)where depl_entry=assoc(
  518. kernel,depl!*))do
  519.  
  520. rplacd(entry,nil . (cddr entry+1))
  521. where entry=assoc(variable,present_variables);
  522.  
  523. %:52%
  524. %line 961 "integrator.web"
  525. ;
  526. %53:%
  527. %line 1007 "integrator.web"
  528.  
  529. %line 1008 "integrator.web"
  530. differentiations_list:=
  531. for each entry in present_variables join
  532. if cadr entry and cddr entry=1 and
  533. (polynomial_order:=get_polynomial_order(
  534. linear_solve(mk!*sq(equation ./ 1),cadr entry),car entry))
  535. then list(car entry . cadr entry . (polynomial_order+1));
  536. if differentiations_list then
  537. if !*allow_differentiation then
  538.  <<for each entry in differentiations_list do
  539. setk(list(current_equation_set!*,(total_used:=total_used+1)),
  540. mk!*sq simpdf list(mk!*sq(equation ./ 1),
  541. car entry,cddr entry));
  542. write current_equation_set!*,"(",n,"): Generation of ",current_equation_set!*,"(",get(current_equation_set!*, 'total_used)+1,
  543. "),...,",current_equation_set!*,"(",total_used,") by differentiation w.r.t. ";
  544. terpri!* t;
  545. maprin partial_list(for each entry in differentiations_list collect
  546. list( 'list,car entry,cddr entry),10);
  547. terpri!* nil;
  548. put(current_equation_set!*, 'total_used,total_used);
  549. goto solved
  550. >> 
  551. else <<
  552. write"*** ",current_equation_set!*,"(",n,
  553. "): Generation of new equations by differentiation possible.";
  554. terpri!* t;write"    Solvable with 'on allow_differentiation'";
  555. terpri!* t;goto solved>> 
  556.  
  557. %:53%
  558. %line 962 "integrator.web"
  559.  
  560.  
  561. %:51%
  562. %line 335 "integrator.web"
  563. ;
  564. %55:%
  565. %line 1054 "integrator.web"
  566.  
  567. %line 1055 "integrator.web"
  568. write current_equation_set!*,"(",n,") not solved";terpri!* t
  569.  
  570. %:55%
  571. %line 336 "integrator.web"
  572. ;
  573. solved:
  574. end$
  575.  
  576. %:15%%20:%
  577. %line 421 "integrator.web"
  578.  
  579. %line 422 "integrator.web"
  580. lisp procedure find_solvable_kernel(kernel_list,kc_list,denominator);
  581. if !*coefficient_check then first_solvable_kernel(kernel_list,kc_list,denominator)
  582. else car kernel_list$
  583.  
  584.  
  585. lisp procedure first_solvable_kernel(kernel_list,kc_list,denominator);
  586. if kernel_list then
  587. (if numberp cdr kc_pair or
  588. numberp !*ff2a(cdr kc_pair,denominator)
  589. then car kc_pair
  590. else first_solvable_kernel(cdr kernel_list,kc_list,denominator))
  591. where kc_pair=assoc(car kernel_list,kc_list)$
  592.  
  593. %:20%%21:%
  594. %line 458 "integrator.web"
  595.  
  596. lisp procedure homogeneous_integration_of df_term;
  597. begin scalar df_function,function_number,dependency_list,integration_list,
  598. coefficient_name,bracketname,even_used,odd_used,
  599. integration_variable,
  600. number_of_integrations,solution,new_dependency_list;
  601. %22:%
  602. %line 483 "integrator.web"
  603.  
  604. df_function:=cadr df_term;
  605. if not member(car df_function,get(current_equation_set!*, 'function_list))
  606. or not fixp(function_number:=cadr df_function)or function_number=0 then
  607.  
  608. msgpri("PERFORM_HOMOGENEOUS_INTEGRATION: integration of",
  609. df_function,"not allowed",nil,t)
  610.  
  611. %:22%
  612. %line 465 "integrator.web"
  613. ;
  614. dependency_list:=
  615. ((if depl_entry then cdr depl_entry)where depl_entry=assoc(df_function,depl!*));
  616. if length dependency_list=1 then
  617. coefficient_name:=get(current_equation_set!*, 'constant_operator)
  618. else coefficient_name:=car df_function;
  619. %23:%
  620. %line 493 "integrator.web"
  621.  
  622. %line 494 "integrator.web"
  623. if get(coefficient_name, 'rtype)= 'algebra_generator then
  624. begin bracketname:=get(current_equation_set!*, 'bracketname);
  625. even_used:=get(bracketname, 'even_used);
  626. odd_used:=get(bracketname, 'odd_used);
  627. end
  628. else
  629. begin
  630. even_used:=get(coefficient_name, 'even_used);
  631. odd_used:=get(coefficient_name, 'odd_used);
  632. end
  633.  
  634. %:23%
  635. %line 470 "integrator.web"
  636. ;
  637. integration_list:=cdr cdr df_term;
  638. %24:%
  639. %line 507 "integrator.web"
  640.  
  641. %line 508 "integrator.web"
  642. if integration_list then integration_variable:=car
  643. integration_list else integration_variable:=nil;
  644. if integration_variable and(integration_list:=cdr integration_list)
  645. and fixp car integration_list then
  646.  <<number_of_integrations:=car integration_list;
  647. integration_list:=cdr integration_list>> 
  648. else number_of_integrations:=1
  649.  
  650. %:24%
  651. %line 472 "integrator.web"
  652. ;
  653. if bracketname then
  654. %25:%
  655. %line 521 "integrator.web"
  656.  
  657. %line 522 "integrator.web"
  658. if function_number>0 then
  659. (if even_used+number_of_integrations>get(bracketname, 'even_dimension)then
  660. change_dimensions_of(bracketname,even_used+number_of_integrations,
  661. get(bracketname, 'odd_dimension)))
  662. else
  663. (if odd_used+number_of_integrations>get(bracketname, 'odd_dimension)then
  664. change_dimensions_of(bracketname,get(bracketname, 'even_dimension),
  665. odd_used+number_of_integrations))
  666.  
  667. %:25%
  668. %line 474 "integrator.web"
  669. ;
  670. %26:%
  671. %line 544 "integrator.web"
  672.  
  673. solution:=nil ./ 1;
  674. while integration_variable do
  675. begin new_dependency_list:=delete(integration_variable,dependency_list);
  676. for i:=0:number_of_integrations-1 do
  677.  <<solution:=addsq(solution,multsq(
  678. if i=0 then 1 ./ 1 else mksq(integration_variable,i),
  679. mksq(
  680. list(coefficient_name,if function_number>0 then
  681. (even_used:=even_used+1)else-(odd_used:=odd_used+1)),1)));
  682. if new_dependency_list then
  683. depl!*:=(list(coefficient_name,if function_number>0 then even_used
  684. else-odd_used) . new_dependency_list) . depl!*;
  685. >> ;
  686. %24:%
  687. %line 507 "integrator.web"
  688.  
  689. %line 508 "integrator.web"
  690. if integration_list then integration_variable:=car
  691. integration_list else integration_variable:=nil;
  692. if integration_variable and(integration_list:=cdr integration_list)
  693. and fixp car integration_list then
  694.  <<number_of_integrations:=car integration_list;
  695. integration_list:=cdr integration_list>> 
  696. else number_of_integrations:=1
  697.  
  698. %:24%
  699. %line 553 "integrator.web"
  700.  
  701. end;
  702. solution:=mk!*sq subs2 solution;
  703.  
  704. if get(coefficient_name, 'rtype)= 'algebra_generator then
  705. define_used(bracketname,list( 'list,even_used,odd_used))
  706. else
  707. begin
  708. put(coefficient_name, 'even_used,even_used);
  709. put(coefficient_name, 'odd_used,odd_used);
  710. end
  711.  
  712. %:26%
  713. %line 475 "integrator.web"
  714. ;
  715. return solution
  716. end$
  717.  
  718. %:21%%31:%
  719. %line 604 "integrator.web"
  720.  
  721. %line 605 "integrator.web"
  722. lisp procedure polynomialp(expression,kernel);
  723. if domainp expression then t
  724. else((main_variable=kernel or not depends(main_variable,kernel))and
  725. polynomialp(lc expression,kernel)and polynomialp(red expression,kernel))
  726. where main_variable=mvar expression$
  727.  
  728. %:31%%33:%
  729. %line 636 "integrator.web"
  730.  
  731. %line 637 "integrator.web"
  732. lisp procedure partial_list(printed_list,nr_of_items);
  733.  'list . broken_list(printed_list,nr_of_items)$
  734.  
  735. lisp procedure broken_list(list,n);
  736. if list then if n=0 then '(!.!.!.)
  737. else car list . broken_list(cdr list,n-1)$
  738.  
  739. %:33%%42:%
  740. %line 806 "integrator.web"
  741.  
  742. %line 807 "integrator.web"
  743. lisp procedure check_differentiation_sequence(sequence,variable_list);
  744. if null sequence then t
  745. else if fixp car sequence or
  746. member(car sequence,variable_list)then
  747. check_differentiation_sequence(cdr sequence,variable_list)$
  748.  
  749. %:42%%46:%
  750. %line 863 "integrator.web"
  751. lisp procedure check_polynomial_integration(df_term,integration_term);
  752. %line 864 "integrator.web"
  753. begin scalar numerator,denominator,integration_variables,variable,ok;
  754. numerator:=numr simp integration_term;
  755. denominator:=denr simp integration_term;
  756. integration_variables:=
  757. for each argument in cdr cdr df_term join
  758. if not fixp argument then list argument;
  759. ok:=t;
  760. while ok and integration_variables do
  761.  <<variable:=car integration_variables;
  762. ok:=(not depends(denominator,variable)and polynomialp(numerator,variable));
  763. integration_variables:=cdr integration_variables
  764. >> ;
  765. return ok;
  766. end$
  767.  
  768. %:46%%47:%
  769. %line 884 "integrator.web"
  770.  
  771. %line 885 "integrator.web"
  772. lisp procedure inhomogeneous_integration_of(df_term,inhomogeneous_term);
  773. begin scalar df_sequence,integration_variables,int_sequence,
  774. variable,nr_of_integrations,integration_terms,solution,
  775. powers,coefficient,int_factor,solution_term,n,k;
  776. df_sequence:=cdr cdr df_term;
  777. %48:%
  778. %line 905 "integrator.web"
  779.  
  780. %line 906 "integrator.web"
  781. while df_sequence do
  782.  <<variable:=car df_sequence;
  783. df_sequence:=cdr df_sequence;
  784. if df_sequence and fixp car df_sequence then
  785.  <<nr_of_integrations:=car df_sequence;
  786. df_sequence:=cdr df_sequence>> 
  787. else nr_of_integrations:=1;
  788. integration_variables:=variable . integration_variables;
  789. int_sequence:=(variable . nr_of_integrations) . int_sequence
  790. >> 
  791.  
  792. %:48%
  793. %line 890 "integrator.web"
  794. ;
  795. integration_terms:=multi_split_form(numr simp inhomogeneous_term,
  796. integration_variables);
  797. integration_terms:=(nil . car integration_terms) . 
  798. cdr
  799. integration_terms;
  800.  
  801. %49:%
  802. %line 924 "integrator.web"
  803.  
  804. %line 925 "integrator.web"
  805. solution:=nil ./ 1;
  806. for each term in integration_terms do
  807.  <<powers:=car
  808. term;coefficient:=cdr term;
  809. int_factor:=1;solution_term:=1 ./ 1;
  810. for each integration in int_sequence do
  811.  <<variable:=car integration;k:=cdr integration;
  812. n:=(if power then cdr power else 0)where power=assoc(variable,powers);
  813.  
  814. for i:=1:k do int_factor:=(n+i)*int_factor;
  815. solution_term:=multsq(solution_term,mksq(variable,n+k))
  816. >> ;
  817. solution_term:=multsq(solution_term,coefficient ./ int_factor);
  818. solution:=addsq(solution,solution_term)
  819. >> 
  820.  
  821. %:49%
  822. %line 896 "integrator.web"
  823. ;
  824. solution:=multsq(solution,1 ./ denr simp inhomogeneous_term);
  825. solution:=mk!*sq subs2 addsq(solution,simp homogeneous_integration_of df_term);
  826. return solution
  827. end$
  828.  
  829. %:47%%54:%
  830. %line 1041 "integrator.web"
  831.  
  832. %line 1042 "integrator.web"
  833. lisp procedure get_polynomial_order(expression,variable);
  834. if not depends(denr(expression:=simp expression),variable)and
  835. (not !*polynomial_check or polynomialp(numr expression,variable))then
  836. begin scalar kord!*;
  837. setkorder list !*a2k variable;
  838. expression:=reorder numr expression;
  839. return if mvar expression=variable then ldeg expression else 0;
  840. end$
  841.  
  842. %:54%%56:%
  843. %line 1063 "integrator.web"
  844.  
  845. %line 1064 "integrator.web"
  846. algebraic procedure integrate_equations(m,n);
  847. for i:=m:n do integrate_equation(i)$
  848.  
  849.  
  850. lisp operator integrate_exceptional_equation;
  851. lisp procedure integrate_exceptional_equation(n);
  852. integrate_equation(n)
  853. where
  854. !*coefficient_check=nil,
  855. !*polynomial_check=nil,
  856. !*allow_differentiation=t$
  857.  
  858.  
  859. %:56%%57:%
  860. %line 1085 "integrator.web"
  861. lisp operator show_equation;
  862. %line 1086 "integrator.web"
  863. lisp procedure show_equation n;
  864. begin scalar equation,total_used,function_list;
  865. if null(total_used:=get(current_equation_set!*, 'total_used))or
  866. n>total_used then
  867.  
  868. msgpri("SHOW_EQUATION: properly initialize",
  869. current_equation_set!*,nil,nil,t);
  870. if(equation:=assoc(list(current_equation_set!*,n),get(current_equation_set!*, 'kvalue)))then
  871. begin
  872. equation:=setk(list(current_equation_set!*,n),aeval cadr equation);
  873. varpri(equation,list( 'setk,mkquote list(current_equation_set!*,n),mkquote equation), 'only);
  874. function_list:=get_recursive_kernels(numr simp equation,
  875. get(current_equation_set!*, 'function_list));
  876. if function_list then
  877.  <<terpri!* t;
  878. for each fn in function_list do
  879.  <<maprin(fn . 
  880. ((if depl_entry then cdr depl_entry)where depl_entry=assoc(fn,depl!*)));terpri!* nil>> 
  881. >> 
  882. else terpri!* nil
  883. end
  884. end$
  885.  
  886.  
  887. algebraic procedure show_equations(m,n);
  888. for i:=m:n do show_equation i$
  889.  
  890. %:57%%58:%
  891. %line 1112 "integrator.web"
  892.  
  893. %line 1113 "integrator.web"
  894. lisp operator functions_used,put_functions_used,equations_used,put_equations_used;
  895.  
  896.  
  897. lisp procedure functions_used function_name;
  898. list( 'list,get(function_name, 'even_used),get(function_name, 'odd_used))$
  899.  
  900.  
  901. lisp procedure put_functions_used(function_name,even_used,odd_used);
  902. begin
  903. if not fixp even_used or even_used<0 or
  904. not fixp odd_used or odd_used<0 then
  905.  
  906. msgpri("PUT_FUNCTIONS_USED: used functions number invalid",nil,nil,nil,t);
  907. put(function_name, 'even_used,even_used);
  908. put(function_name, 'odd_used,odd_used);
  909. end$
  910.  
  911.  
  912. lisp procedure equations_used;
  913. get(current_equation_set!*, 'total_used)$
  914.  
  915.  
  916. lisp procedure put_equations_used(n);
  917. if not fixp n or n<0 then
  918.  
  919. msgpri("PUT_EQUATIONS_USED: used equation number invalid",nil,nil,nil,t)
  920. else put(current_equation_set!*, 'total_used,n)$
  921.  
  922. %:58%%59:%
  923. %line 1149 "integrator.web"
  924.  
  925. %line 1150 "integrator.web"
  926. lisp operator df_acts_as_derivation_on;
  927.  
  928. lisp procedure df_acts_as_derivation_on operator_name;
  929. begin
  930. put(operator_name, 'dfform, 'df_as_derivation);
  931. end$
  932.  
  933. %:59%%60:%
  934. %line 1161 "integrator.web"
  935.  
  936. %line 1162 "integrator.web"
  937. lisp procedure df_as_derivation(kernel,variable,power);
  938. begin scalar left_part,right_part,argument,derivative;
  939. if power neq 1 then
  940.  
  941. msgpri("DF_AS_DERIVATION:",kernel,"must occur linearly",nil,t);
  942. left_part:=list car kernel;right_part:=cdr kernel;
  943. derivative:=nil . 1;
  944. while right_part do
  945.  <<argument:=car right_part;right_part:=cdr right_part;
  946. derivative:=addsq(derivative,
  947. simp append(reverse left_part,list( 'df,argument,variable) . right_part));
  948. left_part:=argument . left_part;
  949. >> ;
  950. return derivative;
  951. end$
  952.  
  953. %:60%%62:%
  954. %line 1191 "integrator.web"
  955.  
  956. %line 1192 "integrator.web"
  957. lisp operator listlength$
  958. lisp procedure listlength l;
  959. listpri_depth!*:=l$
  960.  
  961. %:62%%63:%
  962. %line 1200 "integrator.web"
  963.  
  964. %line 1201 "integrator.web"
  965. symbolic procedure listpri l;
  966. begin scalar orig,split,u;
  967. u:=l;
  968. l:=cdr l;
  969. prin2!* get( '!*lcbkt!*, 'prtch);
  970.  
  971. orig:=orig!*;
  972. orig!*:=if posn!*<18 then posn!* else orig!*+3;
  973. if null l then go to b;
  974. split:=treesizep(l,listpri_depth!*);
  975. a:maprint(negnumberchk car l,0);
  976. l:=cdr l;
  977. if null l then go to b;
  978. oprin '!*comma!*;
  979. if split then terpri!* t;
  980. go to a;
  981. b:prin2!* get( '!*rcbkt!*, 'prtch);
  982. orig!*:=orig;
  983. return u
  984. end$
  985.  
  986. %:63%%64:%
  987. %line 1224 "integrator.web"
  988. end;
  989. %line 1225 "integrator.web"
  990.  
  991. %:64%
  992.